
const fs = require("fs");
const path = require("path");
function deleteDir(dirpath) {
    if(fs.readdirSync(dirpath).length !== 0) {
        fs.readdirSync(dirpath).forEach(item => {
            let filePath = path.join(dirpath , item);
            if(fs.statSync(filePath).isDirectory()) {
                deleteDir(filePath);
            } else if(fs.statSync(filePath).isFile()) {
                fs.unlinkSync(filePath);
            }
        })
    }
    fs.rmdirSync(dirpath);
}
let dirpath = path.join(__dirname , "test");
deleteDir(dirpath);